package xyz.liuyuhe.StudySpring.ch7.cglibproxy;

import java.lang.reflect.Method;

import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

public class DBQueryInterceptor implements MethodInterceptor{
    private Object target;
    
    public DBQueryInterceptor(Object target) {
        this.target = target;
    }
//
//    public Object intercept(Object arg0, 
//            Method arg1, Object[] arg2, MethodProxy arg3) throws Throwable {
//        System.out.println("id:"+arg2[0]);
//        return arg1.invoke(target, arg2);
//    }
    public Object intercept(Object arg0, 
          Method arg1, Object[] arg2, MethodProxy arg3) throws Throwable {
        System.out.println("id:"+arg2[0]);
        return arg3.invokeSuper(arg0, arg2);
    }
    
}
